<template>
	<view style="width: 100vw;height: 100vh;background-color: #EFEFEF;overflow: hidden;">
		<view
			style="background-color: #ffffff;margin: auto; width: 90%;height: 85%; padding: 50rpx 20rpx;margin-top: 40rpx;overflow: auto;border-radius: 10rpx;">
			<u-parse :html="content"></u-parse>
		</view>

		<button style="background-color: skyblue;width: 70%;margin-top: 20rpx;" @click="go_ok">确认理解并严格执行 
			<template v-if="time > 0">
				(<text
						style="color: red;font-weight: 700;">{{time}}s</text>)
			</template>
		</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				time: 20,
			}
		},
		async onLoad() {
			let that = this
			that.pdsDetail()
			clearInterval(timer)
			let timer = setInterval(() => {
				if (that.time <= 1) {
					clearInterval(timer)
				}
				that.time = that.time - 1

			}, 1000)
			// wx.enableAlertBeforeUnload({
			// 	message: "返回上页时弹出对话框",
			// 	success: function(res) {
			// 		console.log("方法注册成功：", res);
			// 	},
			// 	fail: function(errMsg) {
			// 		console.log("失败", errMsg);
			// 	},
			// })

		},


		methods: {
		
			pdsDetail() {
				let that = this,
					U = that.U;
				that.$u.api.pdsDetail().then(res => {
					if (res) {
						that.content = res.data

					}

				});
			},
			go_ok() {
				let that = this,
					U = that.U;
				if (that.time > 1) {
					return uni.showToast({
						title: '请仔细阅读规则',
						duration: 2000,
						icon: 'error'
					});
				} else {
					uni.navigateBack({
						delta: 1
					});
				}
			},



		}
	}
</script>

<style lang="less">
	.my {
		height: 100vh;
		background: #f3f3f3;

		.header {
			overflow: hidden;
			height: 300rpx;
			background: #2979ff;

			.total-balance-title {
				margin-top: 80rpx;
				font-size: 30rpx;
				color: #fff;
				width: 100%;
				text-align: center;
			}

			.total-balance {
				font-size: 60rpx;
				color: #fff;
				width: 100%;
				text-align: center;
				margin-bottom: 20rpx;
			}

			.recharge-btn {
				display: flex;
				justify-content: center;
				padding-bottom: 20rpx;
			}

			.credit-limit {
				margin-top: 10rpx;
				border-top: 2rpx solid #eeeeee;
				padding: 20rpx;

				.cl-title {
					font-size: 30rpx;
					font-weight: 600;
					padding-bottom: 20rpx;
					color: #ffffff;
				}

				.cl-items {
					display: flex;
					justify-content: space-around;

					.cl-line {
						background-color: #eeeeee;
						width: 2rpx;
						margin: 0 20rpx;
					}

					.cl-item {
						text-align: left;
						color: #ffffff;
						flex: auto;

						.cl-item-title {
							padding-bottom: 10rpx;
						}

						.cl-item-money {
							font-weight: 600;
						}
					}
				}


			}
		}

		.row-item-list {
			// margin: 0rpx 10rpx;
			background: #fff;
			margin-top: 10rpx;
			border-radius: 14rpx;
		}
	}
</style>